package com.da.lon.wang.xlg.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.da.lon.wang.xlg.R;
import com.da.lon.wang.xlg.bean.CountrySiftResultBean.CountrySiftBean;

import java.util.ArrayList;

public class CountrySiftRightAdapter extends BaseAdapter {
    ArrayList<CountrySiftBean> datas;
    Context context;
    LayoutInflater inflater;

    public CountrySiftRightAdapter(ArrayList<CountrySiftBean> datas, Context context) {
        this.datas = datas;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return datas != null ? datas.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position).getZu();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = new Holder();
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.sift_right_item, null);
        }
        holder.name = (TextView) convertView.findViewById(R.id.sift_right_name);
        if (position < datas.size()) {
            holder.name.setText(datas.get(position).getZu().toUpperCase());
        }
        if (convertView.getTag() == null) {
            convertView.setTag(holder);
        }
        return convertView;
    }

    class Holder {
        TextView name;
    }
}
